{$CLEO}
0A93:

{--------textBox--------}
//
//    struct textBox      // sizeof = 0x10
//    {
//        float XPos
//        float YPos
//        float XSize
//        float YSize
//    }
//

const
    sizeof_textBox      =   0x10
    
    textBox__SIDE_TOP            =   1    
    textBox__SIDE_BOTTOM         =   2
end

:textBox__New{PtrToSpace_textBox,XPos,YPos,XSize,YSize}
0A9F: 10@ = current_thread_pointer
10@ += 0x3C     // tls
0062: 0@ -= 10@
0@ /= 4

0087: 0@(0@,1f) = 1@
0087: 1@(0@,1f) = 2@
0087: 2@(0@,1f) = 3@
0087: 3@(0@,1f) = 4@
0AB2: ret 1 0@

:textBox__Draw_f{textBox,Float,Precision,Spinner?}
0087: 7@ = 2@(0@,1f)   // XSize
7@ /= 2.0
0087: 8@ = 3@(0@,1f)   // YSize
8@ /= 2.0

0087: 5@ = 0@(0@,1f)   // XPos
0087: 6@ = 1@(0@,1f)   // YPos
0063: 5@ -= 7@
0063: 6@ -= 8@
5@ += 1.0
6@ += 1.0

038E: draw_box_position 0@(0@,1f) 1@(0@,1f) size 2@(0@,1f) 3@(0@,1f) RGBA 255 255 255 255

07FC: text_draw_box_position_XY 5@ 6@ GXT_reference GXTKey_Decimal value 1@ precision 2@

if 3@ == true
then
    0087: 5@ = 0@(0@,1f)    // XPos
    005B: 5@ += 7@   // XSize 
    038D: draw_texture SpinnerTx position 5@ 1@(0@,1f) size SpinnerSizeX SpinnerSizeY RGBA 255 255 255 255
end
0AB2: ret 0


:textBox__Draw_i{textBox,Int,Spinner?}
0087: 7@ = 2@(0@,1f)   // XSize
7@ /= 2.0
0087: 8@ = 3@(0@,1f)   // YSize
8@ /= 2.0

0087: 5@ = 0@(0@,1f)   // XPos
0087: 6@ = 1@(0@,1f)   // YPos
0063: 5@ -= 7@
0063: 6@ -= 8@
5@ += 1.0
6@ += 1.0

038E: draw_box_position 0@(0@,1f) 1@(0@,1f) size 2@(0@,1f) 3@(0@,1f) RGBA 255 255 255 255
045A: draw_text_1number 5@ 6@ GXT GXTKey_Integer number 1@

if 2@ == true
then
    0087: 5@ = 0@(0@,1f)    // XPos
    005B: 5@ += 7@   // XSize 
    038D: draw_texture SpinnerTx position 5@ 1@(0@,1f) size SpinnerSizeX SpinnerSizeY RGBA 255 255 255 255
end
0AB2: ret 0


:textBox__DrawTextAboveMe{textBox,SString}
0087: 21@ = 0@(0@,1f) // XPOS
0087: 22@ = 1@(0@,1f) // YPOS
0087: 23@ = 2@(0@,1f) // XSZ
0087: 24@ = 3@(0@,1f) // YSZ
23@ /= 2.0
24@ += 5.0
0063: 21@ -= 23@
0063: 22@ -= 24@
033E: set_draw_text_position 21@ 22@ GXT 1@s
0AB2: ret 0



:textBox__SpinnerClicked{textBox,Side,MouseX,MouseY}
if 0AB1: call_scm_func @Mouse_IsPressing_LMB 0
jf @ret_0

0087: 7@ = 2@(0@,1f)   // XSize
7@ /= 2.0
0087: 8@ = 3@(0@,1f)   // YSize
8@ /= 2.0

30@ = SpinnerSizeX
30@ /= 2.0
31@ = SpinnerSizeY
31@ /= 2.0

0087: 11@ = 0@(0@,1f) // SpinnerLeftTopX =
005B: 11@ += 7@
0063: 11@ -= 30@

0087: 12@ = 1@(0@,1f) // SpinnerLeftTopY =
0063: 12@ -= 31@

0087: 13@ = 11@       // SpinnerRightBottomX
0087: 14@ = 12@       // SpinnerRightBottomY
13@ += SpinnerSizeX
14@ += SpinnerSizeY



if 1@ == 1  // Top
then
    0063: 14@ -= 31@
end

if 1@ == 2  // Bottom
then
    005B: 12@ += 31@
end

2@ -= MouseSizeXm
3@ -= MouseSizeYm

if 3
0035: 2@ >= 11@
0035: 3@ >= 12@ 
8035: 2@ < 13@
8035: 3@ < 14@

:ret_0
0AB2: ret 0





{ -------- Mouse -------- }
:Mouse_IsPressing_LMB
0@ = 0x00B73418
0A8D: 0@ = read_memory 0@ size 1 virtual_protect 0
0@ <> 0
0AB2: ret 0

:Mouse_IsPressing_RMB
0@ = 0x00B73419
0A8D: 0@ = read_memory 0@ size 1 virtual_protect 0
0@ <> 0
0AB2: ret 0

:Mouse_UsedWheelUp
0@ = 0xB7341B 
0A8D: 0@ = read_memory 0@ size 1 virtual_protect 0 
8039:   not  0@ == 0 
0AB2: ret 0 

:Mouse_UsedWheelDown
0@ = 0xB7341C
0A8D: 0@ = read_memory 0@ size 1 virtual_protect 0 
8039:   not  0@ == 0 
0AB2: ret 0

:Mouse_Update{MouseX, MouseY, RETURNS: MouseX, MouseY}
0A4A: store_joystick_X_offset_to 2@ Y_offset_to 3@      // _currentMouseState.X, _currentMouseState.Y

if 0A4C:   mouse_not_inverted_vertically
then
    3@ *= -1.0
end

0A8D: 4@ = read_memory 0xB6EC1C size 4 virtual_protect 0
006B: 2@ *= 4@
006B: 3@ *= 4@
2@ *= 230.0
3@ *= 230.0

005B: 0@ += 2@
005B: 1@ += 3@

if 0@ < 0.0
then
    0@ = 0.0
else
    if 0@ > 640.0
    then
        0@ = 640.0
    end
end

if 1@ < 0.0
then
    1@ = 0.0
else
    if 1@ > 448.0
    then
        1@ = 448.0
    end
end

0AB2: ret 2 0@ 1@



